﻿using LightCAD.Core.Elements;
using LightCAD.Drawing.Action;
using LightCAD.Drawing.Building;
using LightCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace LightCAD.Drawing
{
    [CommandClass]
    public class ActionCmds
    {
        #region Basic Element

        [CommandMethod(Name = "LINE", ShortCuts = "L")]
        public CommandResult DrawLine(DocumentRuntime docRt, string[] args)
        {
            var lineAction = new LineAction(docRt);
            lineAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "CIRCLE", ShortCuts = "C")]
        public CommandResult DrawCircle(DocumentRuntime docRt, string[] args)
        {
            var circleAction = new CircleAction(docRt);
            circleAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "ELLIPSE", ShortCuts = "EL")]
        public CommandResult DrawEllipse(DocumentRuntime docRt, string[] args)
        {
            docRt.CommandCtrl.WriteInfo("命令：" + "Ellipse");
            var ellipseAction = new EllipseAction(docRt);
            ellipseAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "RAY", ShortCuts = "R")]
        public CommandResult DrawRay(DocumentRuntime docRt, string[] args)
        {
            var rayAction = new RayAction(docRt);
            rayAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "XLINE", ShortCuts = "XL")]
        public CommandResult DrawXLine(DocumentRuntime docRt, string[] args)
        {
            var xlineAction = new XLineAction(docRt);
            xlineAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "POLYLINE", ShortCuts = "PL")]
        public CommandResult DrawPolyLine(DocumentRuntime docRt, string[] args)
        {
            var plineAction = new PolyLineAction(docRt);
            plineAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "ARC", ShortCuts = "AR")]
        public CommandResult DrawArc(DocumentRuntime docRt, string[] args)
        {
            var ArcAction = new ArcAction(docRt);
            ArcAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "QLEADER", ShortCuts = "QL")]
        public CommandResult DrawQleader(DocumentRuntime docRt, string[] args)
        {

            var QleaderAction = new QleaderAction(docRt);
            QleaderAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "DIMRADIAL", ShortCuts = "DIMRAD")]
        public CommandResult DrawDimRadial(DocumentRuntime docRt, string[] args)
        {

            var DimRadialAction = new DimRadialAction(docRt);
            DimRadialAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "ROL", ShortCuts = "RL")]
        public CommandResult DrawRol(DocumentRuntime docRt, string[] args)
        {
            var RolLineAction = new RolLineAction(docRt);
            RolLineAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        /// <summary>
        /// 直径标注
        /// </summary>
        /// <param name="docRt"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        [CommandMethod(Name = "DIMDIAMETER", ShortCuts = "DDI")]
        public CommandResult DrawDDI(DocumentRuntime docRt, string[] args)
        {
            var DimDiameterAction = new DimDiameterAction(docRt);
            DimDiameterAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        /// <summary>
        ///弧长标注
        /// </summary>
        /// <param name="docRt"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        [CommandMethod(Name = "DIMARC", ShortCuts = "DAR")]
        public CommandResult DrawDimArc(DocumentRuntime docRt, string[] args)
        {
            var DimAngularAction = new DimArcLengthAction(docRt);
            DimAngularAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        /// <summary>
        ///坐标标注
        /// </summary>
        /// <param name="docRt"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        [CommandMethod(Name = "DIMORDINATE", ShortCuts = "DOR")]
        public CommandResult DrawDimDor(DocumentRuntime docRt, string[] args)
        {
            var DimOrdinateAction = new DimOrdinateAction(docRt);
            DimOrdinateAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        #endregion

        #region Group
        [CommandMethod(Name = "GROUP", ShortCuts = "G")]
        public CommandResult CreateGroup(DocumentRuntime docRt, string[] args)
        {
            var groupAction = new GroupAction(docRt);
            groupAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "GROUPEDIT", ShortCuts = "")]
        public CommandResult EditGroup(DocumentRuntime docRt, string[] args)
        {
            var groupAction = new GroupAction(docRt);
            groupAction.ExecEdit(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "UNGROUP", ShortCuts = "")]
        public CommandResult Ungroup(DocumentRuntime docRt, string[] args)
        {
            var groupAction = new GroupAction(docRt);
            groupAction.ExecUngroup(args);
            return CommandResult.Succ();
        }
        #endregion

        #region Block
        [CommandMethod(Name = "BLOCK", ShortCuts = "B")]
        public CommandResult CreateBlock(DocumentRuntime docRt, string[] args)
        {
            var blockAction = new BlockAction(docRt);
            blockAction.ExecCreate(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "BEDIT", ShortCuts = "")]
        public CommandResult EditBlock(DocumentRuntime docRt, string[] args)
        {
            var blockAction = new BlockAction(docRt);
            blockAction.ExecEdit(args);
            return CommandResult.Succ();
        }
       

        [CommandMethod(Name = "BLOCKREPLACE", ShortCuts = "")]
        public CommandResult ReplaceBlock(DocumentRuntime docRt, string[] args)
        {
            var blockAction = new BlockAction(docRt);
            blockAction.Replace(args);
            return CommandResult.Succ();
        }



        [CommandMethod(Name = "INSERT", ShortCuts = "")]
        public CommandResult InsertBlock(DocumentRuntime docRt, string[] args)
        {
            var blockRefAction = new BlockRefAction(docRt);
            blockRefAction.ExecInsert(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "REFEDIT", ShortCuts = "")]
        public CommandResult RefEdit(DocumentRuntime docRt, string[] args)
        {
            //if(Xref)new XrefAction();
            var blockAction = new BlockAction(docRt);
            blockAction.ExecRefEdit(args);
            return CommandResult.Succ();
        }

        [CommandMethod(Name = "REFCLOSE", ShortCuts = "")]
        public CommandResult RefClose(DocumentRuntime docRt, string[] args)
        {
            var blockAction = new BlockAction(docRt);
            blockAction.ExecRefClose(args);
            return CommandResult.Succ();
        }
        #endregion

        #region Trans
        [CommandMethod(Name = "SCALE", ShortCuts = "")]
        public CommandResult TransformScale(DocumentRuntime docRt, string[] args)
        {
            TransformAction TransformAction = new TransformAction(docRt);
            TransformAction.ScaleTransform(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "ROTATE", ShortCuts = "")]
        public CommandResult TransformRotate(DocumentRuntime docRt, string[] args)
        {
            TransformAction TransformAction = new TransformAction(docRt);
            TransformAction.RotateTransform(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "MIRROR", ShortCuts = "")]
        public CommandResult TransformMirror(DocumentRuntime docRt, string[] args)
        {
            TransformAction TransformAction = new TransformAction(docRt);
            TransformAction.MirrorTransform(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "MOVE", ShortCuts = "")]
        public CommandResult TransformMove(DocumentRuntime docRt, string[] args)
        {
            TransformAction TransformAction = new TransformAction(docRt);
            TransformAction.MoveTransform(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "OPENUCS", ShortCuts = "")]
        public CommandResult OpenUCS(DocumentRuntime docRt, string[] args)
        {
            UCSAction UCSAction = new UCSAction(docRt);
            UCSAction.OPENUCS(args);
            return CommandResult.Succ();
        }
        #endregion
        #region Building
        [CommandMethod(Name = "Building", ShortCuts = "B")]
        public CommandResult RefBuilding(DocumentRuntime docRt, string[] args)
        {
            var buildingAction = new BuildingAction(docRt);
            buildingAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "BasePoint", ShortCuts = "B")]
        public CommandResult RefBasePoint(DocumentRuntime docRt, string[] args)
        {
            var basePointAction = new BasePointAction(docRt);
            basePointAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "Drawing", ShortCuts = "D")]
        public CommandResult RefDrawing(DocumentRuntime docRt, string[] args)
        {
            var drawingFrameAction = new DrawingFrameAction(docRt);
            drawingFrameAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        #endregion
        [CommandMethod(Name = "DIMLINEAR", ShortCuts = "DLI")]
        public CommandResult DrawDimLinear(DocumentRuntime docRt, string[] args)
        {
            var dimRotatedAction = new DimRotatedAction(docRt);
            dimRotatedAction.ExecCreate(args);
            return CommandResult.Succ();
        }
        [CommandMethod(Name = "DIMALIGNED", ShortCuts = "DAL")]
        public CommandResult DrawDimaLigned(DocumentRuntime docRt, string[] args)
        {
            var dimAlignedAction = new DimAlignedAction(docRt);
            dimAlignedAction.ExecCreate(args);
            return CommandResult.Succ();
        }
    }
}
